package main

import (
	"fmt"
	"runtime"
	"sync"
)

var wg = sync.WaitGroup{}

func read(i int, c chan struct{}) {
	fmt.Printf("goroutine_num: %d, go func: %d\n", runtime.NumGoroutine(), i)
	<-c
	wg.Done()
}

func main() {

	count := 10
	fmt.Println("goroutine_num", runtime.NumGoroutine())
	ch := make(chan struct{}, 3)

	for i := 0; i < count; i++ {
		ch <- struct{}{}
		wg.Add(1)
		go read(i, ch)
	}
	runtime.GC()
}
